home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / include / glibmm-2.4 / glibmm / debug.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-04-20  |  4.2 KB  |  86 lines

  1. // -*- c++ -*-
  2. #ifndef _GLIBMM_DEBUG_H
  3. #define _GLIBMM_DEBUG_H
  4.  
  5. /* $Id: debug.h,v 1.2 2003/01/22 12:08:52 murrayc Exp $ */
  6.  
  7. /* Copyright 2002 The gtkmm Development Team
  8.  *
  9.  * This library is free software; you can redistribute it and/or
  10.  * modify it under the terms of the GNU Library General Public
  11.  * License as published by the Free Software Foundation; either
  12.  * version 2 of the License, or (at your option) any later version.
  13.  *
  14.  * This library is distributed in the hope that it will be useful,
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17.  * Library General Public License for more details.
  18.  *
  19.  * You should have received a copy of the GNU Library General Public
  20.  * License along with this library; if not, write to the Free
  21.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  */
  23.  
  24. #include <glib/gmacros.h>
  25. #include <glibmmconfig.h>
  26.  
  27. // Some stuff that's useful when debugging gtkmm internals:
  28.  
  29. #ifdef GLIBMM_DEBUG_REFCOUNTING
  30.  
  31. #include <glib/gmessages.h>
  32.  
  33. /* We can't use G_GNUC_PRETTY_FUNCTION because it's always disabled in C++,
  34.  * even though __PRETTY_FUNCTION__ works fine in C++ as well if you use it
  35.  * right (i.e. concatenation with string literals isn't allowed).
  36.  */
  37. #ifdef __GNUC__
  38. #define GLIBMM_GNUC_PRETTY_FUNCTION __PRETTY_FUNCTION__
  39. #else
  40. #define GLIBMM_GNUC_PRETTY_FUNCTION ""
  41. #endif
  42.  
  43. #define GLIBMM_DEBUG_REFERENCE(cppInstance, cInstance)                               \
  44.     G_STMT_START{                                                                   \
  45.       void *const cppInstance__ = (void*) (cppInstance);                            \
  46.       void *const cInstance__   = (void*) (cInstance);                              \
  47.       g_log(G_LOG_DOMAIN,                                                           \
  48.             G_LOG_LEVEL_DEBUG,                                                      \
  49.             "file %s: line %d (%s):\n"                                              \
  50.             "ref: C++ instance: %p; C instance: %p, ref_count = %u, type = %s\n",   \
  51.             __FILE__,                                                               \
  52.             __LINE__,                                                               \
  53.             GLIBMM_GNUC_PRETTY_FUNCTION,                                             \
  54.             cppInstance__,                                                          \
  55.             cInstance__,                                                            \
  56.             G_OBJECT(cInstance__)->ref_count,                                       \
  57.             G_OBJECT_TYPE_NAME(cInstance__));                                       \
  58.     }G_STMT_END
  59.  
  60. #define GLIBMM_DEBUG_UNREFERENCE(cppInstance, cInstance)                             \
  61.     G_STMT_START{                                                                   \
  62.       void *const cppInstance__ = (void*) (cppInstance);                            \
  63.       void *const cInstance__   = (void*) (cInstance);                              \
  64.       g_log(G_LOG_DOMAIN,                                                           \
  65.             G_LOG_LEVEL_DEBUG,                                                      \
  66.             "file %s: line %d (%s):\n"                                              \
  67.             "unref: C++ instance: %p; C instance: %p, ref_count = %u, type = %s\n", \
  68.             __FILE__,                                                               \
  69.             __LINE__,                                                               \
  70.             GLIBMM_GNUC_PRETTY_FUNCTION,                                             \
  71.             cppInstance__,                                                          \
  72.             cInstance__,                                                            \
  73.             G_OBJECT(cInstance__)->ref_count,                                       \
  74.             G_OBJECT_TYPE_NAME(cInstance__));                                       \
  75.     }G_STMT_END
  76.  
  77. #else
  78.  
  79. #define GLIBMM_DEBUG_REFERENCE(cppInstance,cInstance)    G_STMT_START{ (void)0; }G_STMT_END
  80. #define GLIBMM_DEBUG_UNREFERENCE(cppInstance,cInstance)  G_STMT_START{ (void)0; }G_STMT_END
  81.  
  82. #endif /* GLIBMM_DEBUG_REFCOUNTING */
  83.  
  84. #endif /* _GLIBMM_DEBUG_H */
  85.  
  86.